package com.yoga.admin.api.web;

import com.yoga.common.appexception.AppException;
import com.yoga.common.appexception.YogaResult;
import com.yoga.common.bo.NoticeMessageBO;
import com.yoga.common.page.PageBO;
import com.yoga.common.qto.NoticeMessageQTO;
import com.yoga.manager.admin.AdminNoticeMessageManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by hdx on 2020/10/19.
 */
@RestController
@RequestMapping("${basePath}")
public class AdminNoticeMessageController {

    @Resource
    private AdminNoticeMessageManager messageManager;

    @PostMapping("/message/add")
    public YogaResult<NoticeMessageBO> addData(NoticeMessageBO noticeMessageBO) throws AppException {
        NoticeMessageBO result = messageManager.addData(noticeMessageBO);

        return new YogaResult<>(result);
    }

    @PostMapping("/message/update")
    public YogaResult<Boolean> updateData(NoticeMessageBO noticeMessageBO) throws AppException {
        Boolean result = messageManager.updateData(noticeMessageBO);

        return new YogaResult<>(result);
    }

    @GetMapping("/message/delete")
    public YogaResult<Boolean> deleteData(Long noticeMessageId) throws AppException {
        Boolean result = messageManager.deleteData(noticeMessageId);

        return new YogaResult<>(result);
    }

    @PostMapping("/message/findById")
    public YogaResult<NoticeMessageBO> findById(Long noticeMessageId) throws AppException {
        NoticeMessageBO result = messageManager.findById(noticeMessageId);

        return new YogaResult<>(result);
    }

    @PostMapping("/message/findByQTO")
    public YogaResult<PageBO<NoticeMessageBO>> findByQTO(NoticeMessageQTO messageQTO) throws AppException {
        PageBO<NoticeMessageBO> result = messageManager.findForPage(messageQTO);

        return new YogaResult<>(result);
    }



}
